﻿using Model.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OMS.Infrastructure
{
    public class UpdateUserLastActivityDateFilter : ActionFilterAttribute, IActionFilter
    {
        private IAuthorizationProvider prov;
        public string username { get; set; }

        public UpdateUserLastActivityDateFilter()
        {
            this.prov = DependencyResolver.Current.GetService<IAuthorizationProvider>();
        }

        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
        {
            var username = filterContext.RequestContext.HttpContext.User.Identity.Name;
            prov.UpdateUserLastActivityDate(username);
        }
    }
}